using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentFeeDetailManager class is responsible for managing BO.StudentFeeDetail objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentFeeDetailManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentFeeDetail objects in the database.
        /// </summary>
        /// <returns>A list with all StudentFeeDetail from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentFeeDetailList GetList()
        {
            return StudentFeeDetailDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentFeeDetail from the database without its data.
        /// </summary>
        /// <param name="stduentFeeKey">The StduentFeeKey of the StudentFeeDetail in the database.</param>
        /// <returns>A StudentFeeDetail object when the StduentFeeKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentFeeDetail GetItem(long SFDKey, int stduentFeeKey)
        {
            return GetItem(SFDKey, stduentFeeKey, false);
        }

        /// <summary>
        /// Gets a single StudentFeeDetail from the database.
        /// </summary>
        /// <param name="stduentFeeKey">The StduentFeeKey of the StudentFeeDetail in the database.</param>
        /// <param name="getStudentFeeDetailRecords">Determines whether to load all associated StudentFeeDetail records as well.</param>
        /// <returns>
        /// A StudentFeeDetail object when the StduentFeeKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentFeeDetail GetItem(long SFDKey, int stduentFeeKey, bool getStudentFeeDetailRecords)
        {
            StudentFeeDetail myStudentFeeDetail = StudentFeeDetailDB.GetItem(SFDKey, stduentFeeKey);
            return myStudentFeeDetail;
        }

        /// <summary>
        /// Saves a StudentFeeDetail in the database.
        /// </summary>
        /// <param name="myStudentFeeDetail">The StudentFeeDetail instance to save.</param>
        /// <returns>The new StduentFeeKey if the StudentFeeDetail is new in the database or the existing StduentFeeKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(StudentFeeDetail myStudentFeeDetail)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int studentFeeDetailStduentFeeKey = StudentFeeDetailDB.Save(myStudentFeeDetail);

                //  Assign the StudentFeeDetail its new (or existing StduentFeeKey).
                myStudentFeeDetail.SFDKey = studentFeeDetailStduentFeeKey;

                myTransactionScope.Complete();

                return studentFeeDetailStduentFeeKey;
            }
        }

        /// <summary>
        /// Deletes a StudentFeeDetail from the database.
        /// </summary>
        /// <param name="myStudentFeeDetail">The StudentFeeDetail instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentFeeDetail myStudentFeeDetail)
        {
            return StudentFeeDetailDB.Delete(myStudentFeeDetail.SFDKey, myStudentFeeDetail.StudentFeeKey);
        }

        #endregion

    }

}
